use "$path\datasets\rd_dataset.dta", clear
keep if in_rdd_sample==1
bysort gkz legislative_period partei: keep if _n==1

gen close=(abs(margin_1)<=0.05)
gen nonclose=(abs(margin_1)>0.05 & abs(margin_1)<.)

hist listenergebnis_winner if close ==1, width(1) color(navy) lcolor(black) xtitle(Rank of winner of last seat)   xlabel(0(5)30) ylabel(0(0.05)0.25) gap(40) frac discrete xlabel(, labsize() angle(horizontal))
graph export FigureA16/figureA16a.pdf, replace

hist listenergebnis_winner if nonclose ==1, width(1) color(navy) lcolor(black) xtitle(Rank of winner of last seat)   xlabel(0(5)30) ylabel(0(0.05)0.25) gap(40) frac discrete xlabel(, labsize() angle(horizontal))
graph export FigureA16/figureA16b.pdf, replace



